Conversation
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1677 |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1740 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1739 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Original PR: #2608 |
|
I just tried to run the branch as-is, and got the following error (pasted below). Looks like input manager is still looking for animal_net_merit in the metadata? |
Should be fixed now! |
|
Current Coverage: % Mypy errors on genetics_implementation branch: 1269 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
There was a problem hiding this comment.
update file path to match the updated location ?
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1267 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1239 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1239 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
thanks for the quick updates Allister! |
|
Hi @YijingGong! Good news is that I FINALLY am coming up for air and this is my top priority for the rest of the week :) More good news: I was able to run both example farms and collected the daily average genetic values to start with. My next step is to look at those values and come up with a plan for interpretation and come up with some edge cases to test. One thing I'd like to point out is that this method really increases the simulation time. Here are the times I got for the two example herds on this branch and dev:
Reducing simulation time is not our primary objective but we do need to keep it in mind aso that we don't make the model unusable for people outside of research domains. One option would be to develop a method to "turn the genetics representation off". @allisterakun and @YijingGong from your intimate knowledge of the methods does this seem like a feasible idea? If so, it wouldn't need to happen in this PR but we should make an issue and start working on it so it is in place before our next release. More to come soon! |
Thanks for doing this testing, Kristan — really useful numbers. The open_lot slowdown especially (6x+) is hard to ignore. I agree a toggle to disable the genetics module is the right direction — and I think it's feasible, though @allisterakun should confirm. I will open an issue to track it so it's on the roadmap before the next release. |
Thanks for catching this, Kristan! I was able to replicate it. The crash is in |


Implements the Genetics submodule into the Animal module, replacing the simple
net_meritattribute with a fullGeneticsclass that tracks true breeding values (TBV), estimated breeding values (EBV), phenotypes, and environmental effects for fat and protein traits.Context
Issue(s) closed by this pull request: closes #
Original PR: #2608. See design doc, PR description, and discussion there.
What
Geneticsclass into theAnimalclass, replacing thenet_meritfloat attribute with a full genetics model tracking TBV, EBV, phenotypes, permanent/temporary environmental effects, and a ranking index for fat and protein traits.GeneticHistorydata type andupdate_genetic_historymethod onAnimalto record genetic state at each simulation day.AnimalConfigto loadaverage_phenotypeandtop_listing_semendatasets during initialization.Animal.__init__to accept aRufasTimeobject instead of asimulation_dayinteger, and to initializeGeneticsdifferently for newborn calves (with optional dam TBV values) vs. existing animals.MilkProductionStatisticsto include genetic attributes (TBV, EBV, phenotype, environmental effects, ranking index).ReproductionInputsto passdam_tbv_fatanddam_tbv_proteininstead ofnet_merit.net_meritfrom all animal typed dicts (CalfValuesTypedDict,HeiferI/II/IIIValuesTypedDict,CowValuesTypedDict).animal_net_meritfromREQUIRED_FILE_BLOBSininput_manager.py.NetMerit_HO.csv,TopListingSemen_HO.csv,mean_phenotype.csv) intoinput/data/animal/animal_genetics/.default.jsonproperties file with genetics-related configuration.simulation_engine.py,herd_factory.py,herd_manager.py, andanimal_module_reporter.pyto accommodate the new genetics integration.RufasTimeparameter, and removednet_meritreferences.util.pywith supporting changes.Why
The previous implementation used a single
net_meritfloat value to represent animal genetics, which was an oversimplification. The newGeneticssubmodule provides a biologically meaningful representation of animal genetics by modeling true breeding values, estimated breeding values, phenotypes, and environmental effects for milk fat and protein traits. This enables more accurate simulation of genetic progress, selection decisions, and milk production variability within the herd.How
The
Geneticsclass computes TBV, EBV, phenotypes, and environmental effects based on birth year, animal type, parity, and optional dam genetic values. For newborn calves with known dam TBV values, genetics are initialized using parental inheritance. For all other animals (existing herd or calves without dam data), genetics are initialized based on population-level data fromaverage_phenotypeandtop_listing_semendatasets loaded intoAnimalConfig. TheAnimalconstructor now requires aRufasTimeobject to determine birth year/month for genetic initialization. Genetic state is tracked over time viaGeneticHistoryrecords appended each simulation day. Thenet_meritfield has been fully replaced by theranking_indexcomputed within theGeneticsclass.Test plan
test_animal.py,test_animal_config.py,test_herd_factory.py,test_herd_manager_daily_routines.py,test_herd_manager_herd_statistics.py,test_animal_module_reporter.py,test_milk_production.py,test_reproduction.py, andtest_simulation_engine.pyto accommodate the newGeneticsintegration andRufasTimeparameter.test_animal_genetics.pyfor theGeneticsclass.Input Changes
input/data/animal/animal_genetics/NetMerit_HO.csv,input/data/animal/animal_genetics/TopListingSemen_HO.csvinput/data/animal_genetics/TopListingSemen_HO.csv,input/data/animal_genetics/mean_phenotype.csv(moved to new location underinput/data/animal/animal_genetics/)freestall_e2e_metadata.json,open_lot_e2e_metadata.json,no_animal_e2e_metadata.json,example_freestall_dairy_metadata.json,example_open_lot_metadata.json,example_no_animal_metadata.json)input/metadata/properties/default.jsonupdated with genetics-related properties.Output Changes
Animal.genetics: NewGeneticsobject replacing thenet_meritfloat attribute.Animal.genetic_history: New list ofGeneticHistoryrecords tracking genetic state over time.Animal.milk_statistics: Now includesTBV_fat,TBV_protein,E_permanent_fat,E_permanent_protein,E_temporary_fat,E_temporary_protein,phenotype_fat,phenotype_protein,EBV_fat,EBV_protein,ranking_index.Animal.net_merit: Removed fromAnimaland all animal typed dicts.Filter
Genetics History
"AnimalModuleReporter._report_all_animals_genetic_history.*"Daily Milk
"AnimalModuleReporter.report_milk.*"Daily Average Genetics (Herd, Calves, HeiferIs, HeiferIIs, HeiferIIIs, Cows)
"AnimalModuleReporter.report_average_genetics.*"